<?php defined("SYSPATH") or die("No direct script access.") ?>
	
<?php // GUEST VIEW ?>
	
<?php if(!$user->admin): ?>
	
   


<pre>
<?php// print_r($parents['0']); ?>
</pre>



<?php if(!$item->parent_id): ?>
	
<script type="text/javascript">
	$(document).ready(function() {
		
	//Main menu horizontal align
		var galleryItem = $('.gallery-root .shadow');
// 			var width;
		galleryItem.each(function(){
			var width = $(this).children('img').width();
			$(this).css('width',  width);
//  				alert(width);
		});
		
		
	});
</script>


<?php endif; ?>


<div class="col borders">
	
	<div class="col-nav">
		
	<?php //Root Album menu
	
	$parentId = 1;
	
	foreach (db::build()
	->select("*")
	->from("items")
	->where("parent_id", "=", $parentId)
	->execute() as $row) {
	
		$albums[$row->title]['url'] = $row->relative_url_cache;
		$albums[$row->title]['id'] = $row->id;
		$albums[$row->title]['description'] = $row->description;
	}
			

	
	?>
	
		<h2>Photographers</h2>
		
		<nav>
	
			<ul>
			<?php
				
				$i = 0;
				foreach ($albums as $key => $album) {
			
			?>

				<li class="item-<?php echo $i; ?>" id="album-<?php echo $album['id']; ?>">
					<a href="<?php echo url::site() .  $album['url']; ?>">
						<?php echo $key; ?>
					</a>
				</li>
		
			<?php		

				}
				$i++;
				?>	
			</ul>
			
		</nav>
		
	</div>
	
</div>
<!--/.col -->

	
<div class="content">
		
	<div class="gallery-container borders">

		<ul class="gallery<?php if(!$item->parent_id): echo ' gallery-root'; endif; ?>">
		<?php foreach ($children as $i => $child): ?>
		
			<?php /*<pre>
			<?php print_r($child); ?>
			</pre>
			<h3><?php echo $item->name . '/' . $child->name; ?></h3>
			<h3><?php echo $child->thumb_url(); ?></h3>
			<h3><?php echo $child->description; ?></h3> */ ?>
		
				<li class="gallery-photo" id="album-<?php echo $item->id; ?>"<?php if($i > 0 and !$item->parent_id): echo ' style="display:none"'; endif; ?>>
				<a class="gallery-photo-pic" href="<?php if($child->is_album()): echo $child->url();else: echo $child->thumb_url(); endif; ?>"<?php if(!$child->is_album()): echo ' rel="shadowbox[bijoux 1]"';endif; ?>>
					<span class="shadow">
						<?= $child->thumb_img(array("class" => "g-thumbnail")) ?>
						<?php if(!$child->is_album() and $child->description): ?>
						<script type="text/javascript">
							$(document).ready(function() {
							//popup
								var galleryItem = $('.gallery .shadow');
								var itemDescription = $('.gallery-photo-description');
								
								galleryItem.each(function(){
	// 							alert('yo');
									$(this).mouseover(function(){
	// 								alert('yo');
										$(this).children('.gallery-photo-description').show('blind');
									}).mouseout(function(){
										$(this).children('.gallery-photo-description').hide('blind');
									});
								});
							});
						</script>
							<span class="gallery-photo-description"><?php echo $child->description; ?></span>
						<?php endif; ?>
					</span>
				</a>
			</li>
		<?php endforeach; ?>
		</ul>
		<!--/.gallery-->
	</div>
	<!--/.gallery-container-->	
		
	<div class="texts borders logo-bg">
		<article>
			
			<?php //Biographies

			if(!$item->parent_id):

			?>
			
			<script>
				$(document).ready(function() {
				
					var listItems = $('.col-nav li');
					var descriptions = $('.g-description, .gallery li');
					descriptions.css('background', 'black');
					var activeId = $('.col-nav .item-0').attr('id');
					var activeElementId = '#' + activeId;
					var activeElement = $(activeElementId);

					alert(activeElementId);
					var menuSlide = function (activeElement){
						
// 						descriptions.hide();		
						activeElement.show();
					
					};
					
// 					activeElement.css('background', 'blue');

					menuSlide(activeElement);

					listItems.each(function(){
						$(this).mouseover(function(activeElement){
							var activeId = $(this).attr('id');
							var activeElementId = '.g-description#' + activeId;
							var activeElement = $(activeElementId);
							
							menuSlide(activeElement);
						});
					});
						
							
					
				});
			</script>
			
			<?php
			$i = 0;

			foreach ($albums as $key => $album) {
				
			?>
			
				<div class="g-description">
					<div id="album-<?php echo $album['id']; ?>">
				
						<h2><?php echo html::purify($key); ?></h2>
					
						<?php echo nl2br(html::purify($album['description'])); ?>
					
				
					</div>
				</div>
		
			<?php

				$i++;

			}
			
			else:
			?>
			
				<h2><?php echo html::purify($item->title); ?></h2>
				<div class="g-description"><?= nl2br(html::purify($item->description)) ?></div>
			
			<?php
			endif;
			?>
		</article>

	</div>
	<!--/.texts-->

</div>
<!--/.content-->

<?php // ADMIN VIEW ?>
 
 <?php else: ?>
 
 <? // @todo Set hover on AlbumGrid list items for guest users ?>
<div id="g-info">
  <?= $theme->album_top() ?>
  <h1><?= html::purify($item->title) ?></h1>
  <div class="g-description"><?= nl2br(html::purify($item->description)) ?></div>
</div>

<ul>
<? if (count($children)): ?>
  <? foreach ($children as $i => $child): ?>
    <? $item_class = "g-photo"; ?>
    <? if ($child->is_album()): ?>
      <? $item_class = "g-album"; ?>
    <? endif ?>
  <li id="g-item-id-<?= $child->id ?>" class="g-item <?= $item_class ?>">
    <? /*= $theme->thumb_top($child)*/ ?>
    <a href="<?= $child->url() ?>">
      <? if ($child->has_thumb()): ?>
      <?= $child->thumb_img(array("class" => "g-thumbnail")) ?>
      <? endif ?>
    </a>
    <? /*= $theme->thumb_bottom($child)*/ ?>
    <? /*= $theme->context_menu($child, "#g-item-id-{$child->id} .g-thumbnail")*/ ?>
    <h2><span class="<?= $item_class ?>"></span>
      <a href="<?= $child->url() ?>"><?= html::purify($child->title) ?></a></h2>
    <!--<ul class="g-metadata">
      <?= $theme->thumb_info($child) ?>
    </ul>-->
  </li>
  <? endforeach ?>
<? else: ?>
  <? if ($user->admin || access::can("add", $item)): ?>
  <? $addurl = url::site("uploader/index/$item->id") ?>
  <li><?= t("There aren't any photos here yet! <a %attrs>Add some</a>.",
            array("attrs" => html::mark_clean("href=\"$addurl\" class=\"g-dialog-link\""))) ?></li>
  <? else: ?>
  <li><?= t("There aren't any photos here yet!") ?></li>
  <? endif; ?>
<? endif; ?>
</ul>
<? /*= $theme->album_bottom()*/ ?>

<?= $theme->paginator() ?>
 

<?php endif ?>

